Nonterminals templ text_ stmt expr tokens token.

Terminals 'text' 'l_delim' 'r_delim' 
		  'if_' 'let_' 'is' 'foreach' 'in' 'else'
		  'end_' 'endif' 'endlet' 'endforeach'

		  'boolean' 'integer' 'string' 'name' 
		  '.' '[' ']' '(' ')' ',' ':'
		  '==' '!=' '<' '<=' '>' '>=' '&&' '||' '!'.


Rootsymbol templ.

templ -> text_ :			''.
templ -> text_ l_delim r_delim templ : ''.
templ -> text_ l_delim stmt r_delim templ : ''.

text_ -> text :		  		templ_dict:append_text(value_of('$1')).

stmt -> if_ expr:			templ_dict:append_if('$2').
stmt -> let_ expr is expr:  templ_dict:append_let('$2', '$4').
stmt -> foreach expr in expr: 
		   	   	   	   	   	templ_dict:append_foreach('$2', '$4').
stmt -> else :				templ_dict:append_else().
stmt -> end_ :				templ_dict:pop_stmt().
stmt -> endif :				templ_dict:pop_if_stmt().
stmt -> endlet :			templ_dict:pop_let_stmt().
stmt -> endforeach :		templ_dict:pop_foreach_stmt().
stmt -> expr :				templ_dict:append_expr('$1').

expr -> tokens :			{expr, '$1'}.

tokens -> token :			['$1'].
tokens -> token tokens :	['$1'|'$2'].

token -> 'boolean' :   		'$1'.
token -> 'integer' :   		'$1'.
token -> 'string' :   		'$1'.
token -> 'name' :   		'$1'.
token -> '.' :   			'$1'.
token -> '[' :   			'$1'.
token -> ']' :   			'$1'.
token -> '(' :   			'$1'.
token -> ')' :   			'$1'.
token -> ',' :   			'$1'.
token -> '==' :   			'$1'.
token -> '!=' :   			'$1'.
token -> '<' :   			'$1'.
token -> '<=' :   			'$1'.
token -> '>' :   			'$1'.
token -> '>=' :   			'$1'.
token -> '&&' :   			'$1'.
token -> '||' :   			'$1'.
token -> '!' :   			'$1'.
token -> ':' :   			'$1'.


Erlang code.
value_of(Token) ->
	element(3, Token).
